class Solution {
public:
    bool isMonotonic(vector<int>& A) {
        bool rise = false, fall = false;
        int n = A.size();
        for(int i = 0; i < n - 1; i++){
            if(A[i] < A[i + 1])rise = true;
            if(A[i] > A[i + 1])fall = true;
            if(rise && fall)return false;
        }
        return true;
    }
};


//2021.2.28
